package com.beerbear.jwt.Context;

import com.beerbear.jwt.Entity.User;

public final class UserContext {
    // 线程拥有
    private static final ThreadLocal<User> user = new ThreadLocal<User>();

    public static void add(User u) {
        user.set(u);
    }

    public static void remove() {
        user.remove();
    }

    /**
     * @return 当前登录用户的用户名
     */
    public static User getCurrentUser() {
        return user.get();
    }
}

